import com.alibaba.druid.pool.DruidDataSource;

public class Main {
    public static void main(String[] args){

        DruidDataSource dataSource = new DruidDataSource();
    dataSource.setUrl("jdbc:mysql://localhost:3306/test");
    dataSource.setUsername("root");
    dataSource.setPassword("azzzzzq123");
    dataSource.setDriverClassName("com.mysql.jdbc.Driver");
    dataSource.setMaxActive(10); //最大连接数

    try{
    if (dataSource.getConnection() !=null){
    System.out.println("连接成功");
    }else{
    System.out.println("连接失败");
    }
    }catch(Exception e){
        throw new RuntimeException(e);
        }
    }

 }